import request from '@/utils/request'
import { AxiosResponse } from 'axios'
import {
  EducationExPerienceType,
  ExpectType,
  GetResumeInfoRes,
  ResumeType,
} from './type'

enum RESUME_API {
  GET_MY_RESUME_INFO = '/sys/resume/findById',
  POST_EDUCATION_EXPERIENCE = '/sys/education/add',
  PUT_RESUME = '/sys/resume/update',
  PUT_EDUCATION_EXPOERIENCE = '/education/update',
  POST_EXPECT = '/except/add',
  PUT_EXPECT = '/except/update',
}

/**
 * 查找简历
 * @returns
 */
export const reqGetMyResumeInfo = () =>
  request.get<any, AxiosResponse<GetResumeInfoRes>>(
    RESUME_API.GET_MY_RESUME_INFO,
  )

/**
 * 更新简历
 * @param {object} params Resume
 * @param {number} params.id
 * @param {number} params.userId
 * @param {string} params.realname
 * @param {number} params.gender
 * @param {object} params.birthdate
 * @param {string} params.currentCity
 * @param {string} params.email
 * @param {string} params.phone
 * @param {number} params.status
 * @param {string} params.advantage
 * @param {string} params.workExperience
 * @param {string} params.projectExperience
 * @param {object} params.createTime
 * @returns
 */
export const reqChangeResuem = (data: ResumeType) =>
  request.post<any, AxiosResponse<any>>(RESUME_API.PUT_RESUME, data)

/**
 * 新增教育经历
 * @param {object} params EducationExperience
 * @param {number} params.id
 * @param {number} params.resumeId
 * @param {string} params.schoolName
 * @param {number} params.type
 * @param {number} params.education
 * @param {string} params.major
 * @param {object} params.enrollmentYear
 * @param {object} params.graduationYear
 * @param {string} params.schoolExperience
 * @param {object} params.createTime
 * @returns
 */
export const reqAddEducationExperience = (data: EducationExPerienceType) =>
  request.post<any, AxiosResponse<any>>(
    RESUME_API.POST_EDUCATION_EXPERIENCE,
    data,
  )

/**
 * 更新教育经历表
 * @param {object} params EducationExperience
 * @param {number} params.id
 * @param {number} params.resumeId
 * @param {string} params.schoolName
 * @param {number} params.type
 * @param {number} params.education
 * @param {string} params.major
 * @param {object} params.enrollmentYear
 * @param {object} params.graduationYear
 * @param {string} params.schoolExperience
 * @param {object} params.createTime
 * @returns
 */
export const reqChangeEducationExperience = (data: EducationExPerienceType) =>
  request.post<any, AxiosResponse<any>>(
    RESUME_API.PUT_EDUCATION_EXPOERIENCE,
    data,
  )

/**
 * 新增求职期望
 * @param {object} params Expect
 * @param {number} params.id
 * @param {number} params.resumeId
 * @param {number} params.type
 * @param {number} params.jobTag
 * @param {string} params.city
 * @param {string} params.otherCity
 * @param {number} params.minSalary
 * @param {number} params.maxSalary
 * @param {number} params.industryId
 * @param {object} params.createTime
 * @returns
 */
export const reqAddExpect = (data: ExpectType) =>
  request.post<any, AxiosResponse<any>>(RESUME_API.POST_EXPECT, data)

/**
 * 更新求职期望
 * @param {object} params Expect
 * @param {number} params.id
 * @param {number} params.resumeId
 * @param {number} params.type
 * @param {number} params.jobTag
 * @param {string} params.city
 * @param {string} params.otherCity
 * @param {number} params.minSalary
 * @param {number} params.maxSalary
 * @param {number} params.industryId
 * @param {object} params.createTime
 * @returns
 */
export const reqChangeExpect = (data: ExpectType) =>
  request.put<any, AxiosResponse<any>>(RESUME_API.PUT_EXPECT, data)
